package game;

import java.util.Random;

/**
 * Date: 2023-04-26
 * Time: 12:12
 */
public class CodeUtil {
    public static String getCode(){
        Random random = new Random();

        char[] chars = new char[52];

        char c = 'a';
        for (int i = 0; i < chars.length; i++) {
            if(c>'z'){
                break;
            }
            chars[i] = c;
            c = (char)(c+1);
        }
        c = 'Z';
        for (int i = chars.length-1; i >0 ; i--) {
            if(c<'A'){
                break;
            }
            chars[i] = c;
            c = (char)(c-1);
        }


        String str = "";

        int k = random.nextInt(4);
        for (int i = 0; i < 5; i++) {
            if(k == i){
                int num = random.nextInt(9)+1;
                str = str+num;
                continue;
            }
            int index = random.nextInt(chars.length);
            str = str+chars[index];
        }
        return str;
    }

}
